<template>
	<view class="pbgf">
		<view class="content bgf">
			<view class="p2432">
				<view class="" v-if="list.length>0">
					<view class="pr mb24 coupon br12" v-for="item in list">
						<image class="w100 h100" src="/static/my/user/coupon/coupon.png" mode=""></image>
						<view class="pa0 w100 h100 br10">
							<view class="coupona flex_c">
								<view class="price flex_col flex_c">
									<view class="tc fw600">
										<text class="fs28">￥</text>
										<text class="fs50">{{item.price}}</text>
									</view>
									<view class="mt4 tc fs24">{{item.money ==0?'无门槛卷':'满'+item.money+'使用'}}</view>
								</view>
								<view class="flex1 mlr50">
									<view class="c3 fw600 fs32 sn1">{{item.name}}</view>
									<view class="mt12 c9 fs20">
										<view class="">有效期：</view>
										<view class="mt4">{{item.workrange}}</view>
									</view>
								</view>
								<view class="coupon_btn flex_c">
									<view class="coupon_btna flex_c fs26" @click="getCoupon(1,item)">立即领取</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="" v-else>
					<u-empty mode="coupon" icon="http://cdn.uviewui.com/uview/empty/coupon.png">
					</u-empty>
				</view>
				<pullUp :status='state'></pullUp>
			</view>
		</view>

		<view class="btn flex_y bgf">
			<view class="btna flex_c cf fw600 fs26 mt20" @click="getCoupon(2)">一键领取</view>
		</view>

	</view>
</template>

<script>
	import {
		pageSize
	} from '@/components/minxins.js' //引入minxins
	export default {
		mixins: [pageSize],
		components: {},
		data() {
			return {
				list: [], //优惠券列表
			}
		},
		onLoad() {
			this.method_name = 'couponList'
			this.query = {
				type: 1
			}
			this.getList();
		},
		onShow() {

		},
		methods: {
			getCoupon(e, item) { //1立即领取 2一键领取
				if (e == 1) {
					this.receiveCoupon({ids:item.id})
				} else if (e == 2) {
					this.receiveCoupon()
				}
			},
			receiveCoupon(e) { //领取接口
				this.$api.receiveCoupon(e).then(res => {
					if (res.code == 1) {
						this.query = {
							type: 1,
							page: 1
						}
						this.getList();
					}
					uni.$u.toast(res.msg)
				})
			}
		},
		computed: {

		},
		watch: {

		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding-bottom: calc(120upx + env(safe-area-inset-bottom));

		.coupon {
			height: 166upx;

			.coupona {
				height: 118upx;
				padding: 24upx;
			}

			.price {
				width: 130upx;
				height: 100%;
				color: #FAE9AB;
			}

			.coupon_btn {
				width: 160upx;
				height: 100%;

				.coupon_btna {
					width: 148upx;
					height: 52upx;
					background: #CD3314;
					box-shadow: 0px 0px 4upx 0px rgba(198, 198, 198, 0.5);
					border-radius: 41upx;
					color: #FAE9AB;
				}
			}
		}
	}

	.btn {
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		padding-bottom: calc(20upx + env(safe-area-inset-bottom));

		.btna {
			width: 440upx;
			height: 80upx;
			background: #CD3314;
			border-radius: 41upx;
		}
	}
</style>
